import read_txt_split_by_space as rts
from sensor_training import sensor_training
from split_Train_Label import split_train_label
from predict import predict_by_weighted_sum
from sensor_training import read_model_params
# read data
data = rts.read_txt_split_by_space(r'7-深度学习基本原理-三好学生案例\dataset\2.txt')
# split data into train and label
X_train, y_train = split_train_label(data)

# training model by sensor_training
# weights, bias = sensor_training(X_train, y_train)
# print("训练完成后的权重:", weights)
# print("训练完成后的偏置:", bias)

# 读取模型参数
weights, bias = read_model_params(r'judge_model.txt')
print("读取到的权重:", weights)
print("读取到的偏置:", bias)
# 用训练后的参数去预测新的样本
input = [78, 40, 90]
print("输入为",input,"的预测结果:", predict_by_weighted_sum(input, weights, bias))
# 而真实值是真实权重与特征值的点积
true_weights = [0.8, 0.18, 0.02]
true_label = sum([input[j] * true_weights[j] for j in range(len(true_weights))])
print("输入为",input,"的真实值:", true_label)
